package com.bjpowernode.threadpool.submit;

import java.util.concurrent.*;

public class Test02 {

    public static void main(String[] args) throws Exception {
        //基于Executor框架实现线程池
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                8,
                16,
                15,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(1024),
                Executors.defaultThreadFactory(),
                //Executors.privilegedThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );

        Future<?> future = threadPoolExecutor.submit(() -> {
            System.out.println("execute start......");
            /*try {
                int a = 10 / 0;
            } catch (Exception e) {
                e.printStackTrace();
            }*/
            System.out.println("execute end......");
            return 100;
        });
        future.get();

        threadPoolExecutor.shutdown();
    }
}
